#include<iostream>
#include<cstdio>
using namespace std;
long long a,b,c,d[200100],e[200100],f,g=1,h[200100],i[200100];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%lld",&a);
	for(int x=1;x<=a;x++){
		scanf("%lld",&d[x]);
		if(d[x]!=d[x-1]&&x>1){
			e[++c]=b;
			h[c]=g;
			i[c]=d[g];
			b=1;
			g=x;
		}else b++;
	}
	e[++c]=b;
	h[c]=g;
	i[c]=d[g];
	b=1;
	while(f<a){
		long long j=0,m=0;
		for(int x=1;x<=c;x++){
			if(!e[x]||j==i[x]) continue;
			printf("%lld ",h[x]);
			h[x]++;
			e[x]--;
			j=i[x];
			f++;
			m=x;
    	}
    	printf("\n");
	}
}
